﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;

namespace WoChu.RfClient.Duty
{
    public class LocationGoodsUIRule
    {
        private static LocationGoodsUIRule _NewInstance = new LocationGoodsUIRule();

        public static LocationGoodsUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new LocationGoodsUIRule();
                }

                return _NewInstance;
            }
        }

        public ResultModel<bool> SetLocationGoods(string userID, List<LocationGoodsInfo> lstLocationGoods)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<ILocationGoods>.NewInstance.InvokeWebMethod<List<LocationGoodsInfo>, ResultModel<bool>>("SetLocationGoods", new object[] { userID }, lstLocationGoods);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return new ResultModel<bool>().GetInstance();
        }
        public ResultModel<bool> SetLocationGoods(string userID, string LocationCode, string GoodsCode, int status) {


            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<ILocationGoods>.NewInstance.InvokeWebMethod<List<LocationGoodsInfo>, ResultModel<bool>>("SetLocationGoods", new object[] { userID, LocationCode, GoodsCode, status },null);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return new ResultModel<bool>().GetInstance();

        }
        public ResultModel<List<LocationGoodsInfo>> GetLocationALLGoods(string goodsCode,  string locationCode)
        {
            try
            {
                var _result= WoChu.CF.BaseFrame.WebClient.WebGetHelper<ILocationGoods>.NewInstance.InvokeWebMethod < ResultModel<List<LocationGoodsInfo>>>("GetLocationALLGoods", new object[] { goodsCode, locationCode });
                if (_result == null)
                    return new ResultModel<List<LocationGoodsInfo>>().GetInstance();
                return _result;

            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return new ResultModel<List<LocationGoodsInfo>>().GetInstance();
        }
        public ResultModel<bool> LocationGoodsMove(string userID, string toLocationCode, List<LocationGoodsInfo> lstLocationGoods)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<ILocationGoods>.NewInstance.InvokeWebMethod<List<LocationGoodsInfo>, ResultModel<bool>>("LocationGoodsMove", new object[] { userID, toLocationCode }, lstLocationGoods);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return new ResultModel<bool>().GetInstance();
        }

        public ResultModel<LocationGoodsInfo> LocationGoodsInfoByCode(string goodsCode, string goodsCode3)
        {
            try
            {
                var _result= WoChu.CF.BaseFrame.WebClient.WebGetHelper<ILocationGoods>.NewInstance.InvokeWebMethod < ResultModel<LocationGoodsInfo>>("LocationGoodsInfoByCode", new object[] { goodsCode, goodsCode3 });

                if (_result == null)
                    return new ResultModel<LocationGoodsInfo>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
            }
            return new ResultModel<LocationGoodsInfo>().GetInstance();
        }
   
        public ResultModel<LocationGoodsInfo> GetLocationInfoByCode(string locationCode)
        {
            try
            {
                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<ILocationGoods>.NewInstance.InvokeWebMethod<ResultModel<LocationGoodsInfo>>("GetLocationInfoByCode", new object[] { locationCode });
                if (_result == null)
                    return new ResultModel<LocationGoodsInfo>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<LocationGoodsInfo>().GetInstance();
            }
        }
       

    }
}
